
package jfireeagle;

import java.util.StringTokenizer;

/**
 * 
 * 
 * @see GpsCoordinate
 *
 */
public class GpsBox 
{
	
	private GpsCoordinate lowerLeftCorner;
	private GpsCoordinate upperRightCorner;

	public GpsBox()
	{
		super();
	}
	
	public GpsBox(String value)
	{
		StringTokenizer tokenizer = new StringTokenizer(value, ",\n\t ");
		if (tokenizer.countTokens() != 4)
		{
			throw new IllegalArgumentException("bad arg: " + value);
		}
		
		lowerLeftCorner = new GpsCoordinate(tokenizer.nextToken(), tokenizer.nextToken());
		
		upperRightCorner = new GpsCoordinate(tokenizer.nextToken(), tokenizer.nextToken());
		
	}
	
	public GpsBox(GpsCoordinate left, GpsCoordinate right)
	{
		this.lowerLeftCorner = left;
		this.upperRightCorner = right;
	}
	
	public GpsCoordinate getLowerLeftCorner()
	{
		return lowerLeftCorner;
	}
	
	public void setLowerLeftCorner(GpsCoordinate lowerLeftCorner)
	{
		this.lowerLeftCorner = lowerLeftCorner;
	}
	
	public GpsCoordinate getUpperRightCorner()
	{
		return upperRightCorner;
	}
	
	public void setUpperRightCorner(GpsCoordinate upperRightCorner)
	{
		this.upperRightCorner = upperRightCorner;
	}

	public String toString()
	{
		return String.valueOf(getLowerLeftCorner())
				+ " "
				+ String.valueOf(getUpperRightCorner());
	}
}
